package jt.android.platformania.world;

import android.graphics.Point;

//Platform is the standard surface material and is represented by a rectangle of varying thickness
public class Platform extends Object {
	
	private Point 	loc2;
	private int		length,
					thickness;
	
	//friction and sprint coefficients
	
	//construct a platform with endpoints at p1 and p2
	public Platform(Point p1, Point p2) 
	{
		setLocation(p1);
		setLocation2(p2);
		setPhased(false);
		//thickness = default thickness
		//setImageID(something);

	}
	
	//construct a phased platform with an anchor point 
	public Platform(Point p) 
	{
		setLocation(p);
		setPhased(true);
		//setImageID(something);
	}
	
	//setting the second endpoint of the platform updates the length;
	public void 	setLocation2(Point p) 			{ loc2 = p; }
	public void 	setLocation2(int x, int y) 		{ loc2.set(x, y); }
	public Point 	getLocation2()					{ return loc2; }
	
	//thickness set and get
	public void 	setThickness(int i)				{ thickness = i; }
	public int 		getThickness()					{ return thickness; }
	
	//length update, set and get
	public void 	updateLength()				
	{ 
		Point p1 = getLocation();
		Point p2 = getLocation2();
		length = (int) (Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2))); 
	}
	public void		setLength(int i)				{ length = i; }
	public int		getLength()						{ return length; }
	
	//overwritten phased method
	//platform has a length so long as it is not phased
	//this prevents the length from being calculated during a resize
	public void 	setPhased(boolean b)
	{
		super.setPhased(b);
		if(getPhased()) setLength(0);
		else updateLength();
	}

	@Override
	public void update() {
		// TODO Auto-generated method stub
		
	}

}
